﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NLite.Domain
{
    /// <summary>
    /// 
    /// </summary>
    public interface IEntity : IEntity<long> { }

    /// <summary>
    /// 实体接口（含有标帜的实体称为实体）,一个实体内只可以聚合一个值对象
    /// </summary>
    /// <typeparam name="TIdentity">标帜类型</typeparam>
    public interface IEntity<TIdentity>
    {
        /// <summary>
        /// 得到标帜
        /// </summary>
        TIdentity Id { get; }
    }

    /// <summary>
    /// 
    /// </summary>
    public interface IVersion
    {
        /// <summary>
        /// 
        /// </summary>
        long Version { get; set; }
    }

    /// <summary>
    /// 
    /// </summary>
    public interface IAggregateRoot : IEntity
    {

    }

    /// <summary>
    /// 领域事件数据接口
    /// </summary>
    public interface IDomainEventData : IEntity,IVersion
    {
        /// <summary>
        /// 得到聚合跟类型
        /// </summary>
        string Type { get; }
        /// <summary>
        /// 得到领域事件的序号
        /// </summary>
        long Order { get; }
    }

    /// <summary>
    /// 领域事件数据类
    /// </summary>
    public class DomainEventData : IDomainEventData
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <param name="sequence"></param>
        public DomainEventData(long id, string type, long sequence)
        {
            Id = id;
            Type = type;
            Order = sequence;
        }
        /// <summary>
        /// 
        /// </summary>
        public string Type { get; private set; }
        /// <summary>
        /// 
        /// </summary>
        public long Id { get; private set; }
        /// <summary>
        /// 
        /// </summary>
        public long Order { get; private set; }
        /// <summary>
        /// 
        /// </summary>
        public long Version { get; set; }
    }
}
